package com.liang.lollipop.lreader;

import android.content.Context;
import android.graphics.Point;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

/**
 * Created by Lollipop on 2017/09/16.
 * 蒙版的View
 */
public class MaskingView extends View {

    private Point viewSize = null;

    public void setViewSize(Point viewSize) {
        this.viewSize = viewSize;
        Log.d("viewSize",viewSize.toString());
    }

    public MaskingView(Context context) {
        this(context,null);
    }

    public MaskingView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public MaskingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr,0);
    }

    public MaskingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if(viewSize!=null){
            setMeasuredDimension(viewSize.x,viewSize.y);
        }else{
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    }
}
